home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / frasr182.zip / FRACTINT.C < prev    next >
C/C++ Source or Header  |  1993-08-18  |  56KB  |  1,757 lines

  1. /*
  2.     FRACTINT - The Ultimate Fractal Generator
  3.             Main Routine
  4. */
  5.  
  6. #include <stdlib.h>
  7. #include <stdio.h>
  8. #include <string.h>
  9. #include <time.h>
  10. #ifndef XFRACT
  11. #include <dos.h>
  12. #include <stdarg.h>
  13. #else
  14. #include <varargs.h>
  15. #endif
  16. #include <ctype.h>
  17. #include "prototyp.h"
  18. /* routines in this module    */
  19.  
  20. static void cmp_line_cleanup();
  21. static void move_zoombox(int);
  22. static int call_line3d(BYTE *pixels, int linelen);
  23. void clear_zoombox();
  24. static void note_zoom();
  25. static void restore_zoom();
  26. static void setup287code();
  27.  
  28. #ifndef XFRACT
  29. extern    int timer(int timertype,int(*subrtn)(),...);
  30. #else
  31. extern  int timer();
  32. #endif
  33.  
  34. #define PUTTHEMHERE 1        /* stuff common external arrays here */
  35.  
  36. #include "fractint.h"
  37. #include "mpmath.h"
  38. #include "fractype.h"
  39. #include "helpdefs.h"
  40.  
  41. long timer_start,timer_interval;    /* timer(...) start & total */
  42. extern int  timerflag;
  43.  
  44. int    adapter;        /* Video Adapter chosen from list in ...h */
  45.  
  46. extern double xcjul, ycjul;
  47. extern int soundflag;
  48. extern int julibrot;
  49.  
  50. extern char gifmask[];
  51. extern int TPlusErr;
  52.  
  53. extern int save_release, bailout;
  54. extern int Transparent3D, far NewTPFractal, tpdepth;
  55. extern int AntiAliasing, Shadowing;
  56. extern int pot16bit;        /* save 16 bit values for continuous potential */
  57. extern int disk16bit;        /* disk video up & running with 16 bit values */
  58. extern int video_type;        /* coded value indicating video adapter type */
  59. extern int usr_biomorph;
  60. extern int escape_exit;
  61. extern int forcesymmetry;
  62. extern float  screenaspect;
  63. extern    char    readname[];    /* name of fractal input file */
  64. extern    int    showfile;    /* zero if display of file is pending */
  65. #define MAXHISTORY    10    /* save this many historical rcds */
  66. struct historystruct {        /* history structure */
  67.     int fractype;        /* fractal type */
  68.     double param[MAXPARAMS];/* parameters   */
  69.     double xxmin;        /* top left    */
  70.     double yymax;        /* top left    */
  71.     double xxmax;        /* bottom right */
  72.     double yymin;        /* bottom right */
  73.     double xx3rd;        /* bottom left    */
  74.     double yy3rd;        /* bottom left    */
  75.     } far *history;
  76.  
  77. char *fract_dir1="", *fract_dir2="";
  78.  
  79. #ifdef __TURBOC__
  80.  
  81. /* yes, I *know* it's supposed to be compatible with Microsoft C,
  82.    but some of the routines need to know if the "C" code
  83.    has been compiled with Turbo-C.  This flag is a 1 if FRACTINT.C
  84.    (and presumably the other routines as well) has been compiled
  85.    with Turbo-C. */
  86. int compiled_by_turboc = 1;
  87.  
  88. /* set size to be used for overlays, a bit bigger than largest (help) */
  89. unsigned _ovrbuffer = 54 * 64; /* that's 54k for overlays, counted in paragraphs */
  90.  
  91. #else
  92.  
  93. int compiled_by_turboc = 0;
  94.  
  95. #endif
  96.  
  97. extern char savename[];     /* save files using this name */
  98. extern char preview;        /* 3D preview mode flag */
  99. extern char temp1[];        /* temporary strings        */
  100. extern int  debugflag;        /* internal use only - you didn't see this */
  101. /*
  102.    the following variables are out here only so
  103.    that the calcfract() and assembler routines can get at them easily
  104. */
  105.     int    active_system = 0;    /* 0 for DOS, WINFRAC for Windows */
  106.     int    dotmode;        /* video access method        */
  107.     int    textsafe2;        /* textsafe override from videotable */
  108.     int    oktoprint;        /* 0 if printf() won't work */
  109.     int    sxdots,sydots;        /* # of dots on the physical screen    */
  110.     int    sxoffs,syoffs;        /* physical top left of logical screen */
  111.     int    xdots, ydots;        /* # of dots on the logical screen     */
  112.     double    dxsize, dysize;     /* xdots-1, ydots-1        */
  113.     int    colors;         /* maximum colors available */
  114.     int    maxit;            /* try this many iterations */
  115.     int    boxcount;        /* 0 if no zoom-box yet     */
  116.     int    zrotate;        /* zoombox rotation        */
  117.     double    zbx,zby;        /* topleft of zoombox        */
  118.     double    zwidth,zdepth,zskew;    /* zoombox size & shape     */
  119.  
  120.     int    fractype;        /* if == 0, use Mandelbrot  */
  121.     char    stdcalcmode;        /* '1', '2', 'g', 'b'       */
  122.     long    creal, cimag;        /* real, imag'ry parts of C */
  123.     long    delx, dely;        /* screen pixel increments  */
  124.     long    delx2, dely2;        /* screen pixel increments  */
  125.     double    delxx, delyy;        /* screen pixel increments  */
  126.     double    delxx2, delyy2;     /* screen pixel increments  */
  127.     long    delmin;         /* for calcfrac/calcmand    */
  128.     double    ddelmin;        /* same as a double        */
  129.     double    param[MAXPARAMS];    /* parameters               */
  130.     double    potparam[3];        /* three potential parameters*/
  131.     long    fudge;            /* 2**fudgefactor        */
  132.     long    l_at_rad;        /* finite attractor radius  */
  133.     double    f_at_rad;        /* finite attractor radius  */
  134.     int    bitshift;        /* fudgefactor            */
  135.  
  136.     int    badconfig = 0;        /* 'fractint.cfg' ok?       */
  137.     int    diskisactive;        /* disk-video drivers flag  */
  138.     int    diskvideo;        /* disk-video access flag   */
  139.     int hasinverse = 0;
  140.     /* note that integer grid is set when integerfractal && !invert;    */
  141.     /* otherwise the floating point grid is set; never both at once     */
  142.     long    far *lx0, far *ly0;    /* x, y grid            */
  143.     long    far *lx1, far *ly1;    /* adjustment for rotate    */
  144.     /* note that lx1 & ly1 values can overflow into sign bit; since     */
  145.     /* they're used only to add to lx0/ly0, 2s comp straightens it out  */
  146.     double far *dx0, far *dy0;    /* floating pt equivs */
  147.     double far *dx1, far *dy1;
  148.     int    integerfractal;     /* TRUE if fractal uses integer math */
  149.  
  150.     /* usr_xxx is what the user wants, vs what we may be forced to do */
  151.     char    usr_stdcalcmode;
  152.     int    usr_periodicitycheck;
  153.     int    usr_distest;
  154.     char    usr_floatflag;
  155.  
  156.     int    viewwindow;        /* 0 for full screen, 1 for window */
  157.     float    viewreduction;        /* window auto-sizing */
  158.     int    viewcrop;        /* nonzero to crop default coords */
  159.     float    finalaspectratio;    /* for view shape and rotation */
  160.     int    viewxdots,viewydots;    /* explicit view sizing */
  161. extern    int    inside;         /* inside color: 1=blue     */
  162. extern    int    outside;        /* outside color, if set    */
  163. extern    int    cyclelimit;        /* color-rotator upper limit */
  164. extern    int    display3d;        /* 3D display flag: 0 = OFF */
  165. extern    int    overlay3d;        /* 3D overlay flag: 0 = OFF */
  166. extern    int    boxcolor;        /* zoom box color */
  167. extern    int    color_bright;        /* set by find_special_colors */
  168.  
  169. #ifndef XFRACT
  170. extern BYTE dacbox[256][3];    /* Video-DAC (filled in by SETVIDEO) */
  171. extern BYTE olddacbox[256][3]; /* backup copy of the Video-DAC */
  172. #else
  173. BYTE dacbox[256][3];   /* Video-DAC (filled in by SETVIDEO) */
  174. BYTE olddacbox[256][3]; /* backup copy of the Video-DAC */
  175. #endif
  176. extern struct videoinfo far videotable[];
  177. extern BYTE far *mapdacbox;    /* default dacbox when map= specified */
  178. extern int    daclearn, daccount;    /* used by the color-cyclers */
  179. extern SEGTYPE    extraseg;        /* used by Save-to-DISK routines */
  180. extern int    cpu;            /* cpu type            */
  181. extern int    fpu;            /* fpu type            */
  182. extern int    iit;            /* iit fpu?            */
  183. extern int    lookatmouse;        /* used to select mouse mode    */
  184. extern int    (*outln)(BYTE *, int);    /* called in decoder */
  185.        void    (*outln_cleanup)();
  186. extern int    filetype;        /* GIF or other */
  187.  
  188. /* variables defined by the command line/files processor */
  189. extern    double    inversion[];
  190. extern    int    invert;     /* non-zero if inversion active */
  191. extern    int    initbatch;    /* 1 if batch run (no kbd)  */
  192.                  /* 2 batch, no save */
  193.                  /* 3 user interrupt, errorlevel 2 */
  194.                  /* 4 program error errorlevel 1, save */
  195.                  /* 5 program error errorlevel 1, don't save */
  196.                 /* -1 complete first, then set to 1 */
  197.  
  198. extern    int    initmode;        /* initial video mode        */
  199. extern    int    goodmode;        /* video.asm sets nonzero if mode ok */
  200. extern    int    initcyclelimit;     /* initial cycle limit        */
  201. extern    int    LogFlag;        /* non-zero if logarithmic palettes */
  202. extern    int    reallyega;        /* == 0 if it's really an EGA */
  203.  
  204. extern char showbox;        /* flag to show box and vector in preview */
  205. extern unsigned initsavetime;    /* timed save interval */
  206.  
  207. int    comparegif=0;            /* compare two gif files flag */
  208. int    timedsave=0;            /* when doing a timed save */
  209. extern long saveticks, savebase;    /* timed save vars for general.asm */
  210. extern int  finishrow;            /* for general.asm timed save */
  211. int    resave_flag=0;            /* tells encoder not to incr filename */
  212. int    started_resaves=0;        /* but incr on first resave */
  213. int    save_system;            /* from and for save files */
  214. int    tabmode = 1;            /* tab display ena